//
//  UIBarButtonItem+Extension.swift
//  weibo
//
//  Created by yellow on 15/10/26.
//  Copyright © 2015年 yellow. All rights reserved.
//

import UIKit

extension UIBarButtonItem{

    /// 工具按钮的便利构造函数，里面是用的UIButton，当有监听方法名就注册点击监听事件
    ///
    /// - parameter imageName:  btn的图片
    /// - parameter target:     监听对象
    /// - parameter actionName: 监听方法名
    ///
    /// - returns: UIBarButtonItem的实例
    convenience init(imageName:String,target:AnyObject?,actionName:String?) {
        let btn = UIButton(imageName: imageName, backImageName: nil)
        if let action = actionName {
            btn.addTarget(target, action: Selector(action), forControlEvents: .TouchUpInside)
        }
        self.init(customView: btn)
    }
}
